home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / rettig.arc / TRSOURCE.EXE / ISDRIVE.ASM < prev    next >
Assembly Source File  |  1990-10-22  |  7KB  |  139 lines

  1. ;----------------------------------------------------------------------------
  2. ;  ISDRIVE.ASM
  3. ;
  4. ;  by Leonard Zerman
  5. ;
  6. ; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. ;----------------------------------------------------------------------------
  8.  
  9.                 PUBLIC  isdrive
  10.                 EXTRN __PARINFO:FAR
  11.                 EXTRN __PARC:FAR
  12.                 EXTRN __RETL:FAR
  13.  
  14. ;----------------------------------------------------------------------------
  15. vect_num1       equ     24h                    ; the int to redirect
  16. dos_int         equ     21h                    ;
  17. toupper         equ     0DFh                   ; force to upper case
  18. ;----------------------------------------------------------------------------
  19. isdrive_text  segment byte public 'CODE'
  20.         assume  cs:isdrive_text
  21. isdrive         proc    far                    ;
  22. ;----------------------------------------------------------------------------
  23. start:          jmp     begin                  ;
  24.                                                ;
  25. old_v_1         dd      ?                      ; storage for old int vector
  26. errorflag       db      0                      ;
  27. parm_passed     db      0                      ;
  28. sector_buffer   db      512 dup (0)            ;
  29. ;----------------------------------------------------------------------------
  30. crit_handler:   mov     cs:errorflag,1         ;
  31.                 xor     ax,ax                  ;
  32.                 iret                           ;
  33. ;----------------------------------------------------------------------------
  34. begin:          push    bp                     ;
  35.                 mov     bp,sp                  ;
  36.                 xor     ax,ax                  ;
  37.                 mov     cs:errorflag, al       ; 
  38.                 mov     cs:parm_passed, al     ; 
  39.                 push    ax                     ;
  40.                 call    __PARINFO              ; check for 1 parm
  41.                 add     sp,2                   ;
  42.                 cmp     ax,1                   ;
  43.                 je      check4parm             ;
  44.                 jmp     getvect                ;
  45. check4parm:     mov     ax,1                   ;
  46.                 push    ax
  47.                 call    __PARINFO              ; check for character
  48.                 add     sp,2                   ;
  49.                 cmp     ax,1                   ;
  50.                 je      set_parm               ;
  51.                 mov     cs:errorflag,1         ;
  52.                 jmp     exit                   ;
  53. set_parm:       mov     cs:parm_passed,1       ;
  54. getvect:        push    ds                     ;
  55.                 mov     ah,35h                 ; get vector address
  56.                 mov     al,vect_num1           ; 
  57.                 int     dos_int                ;
  58.                 mov     word ptr old_v_1,bx    ; save old int address
  59.                 mov     word ptr old_v_1[2],es ;
  60. ;----------------------------------------------------------------------------
  61.                 mov     ah,25h                 ; set new pointer
  62.                 mov     al,vect_num1           ; 
  63.                 mov     dx,cs                  ;
  64.                 mov     ds,dx                  ;
  65.                 mov     dx,offset crit_handler ; set pointer IP (CS & DS same)
  66.                 int     dos_int                ;
  67.                 pop     ds                     ;
  68. ;----------------------------------------------------------------------------
  69.                 mov     al, cs:parm_passed     ;
  70.                 or      al, al                 ;
  71.                 jz      set_default            ;
  72.                 push    es                     ;
  73.                 push    bx                     ;
  74.                 mov     ax,1                   ;
  75.                 push    ax                     ;
  76.                 call    __PARC                 ;
  77.                 add     sp,2                   ;
  78.                 mov     es,dx                  ;
  79.                 mov     bx,ax                  ;
  80.                 mov     dl,byte ptr es:[bx]    ; Load drive letter
  81.                 pop     bx                     ;
  82.                 pop     es                     ;
  83.                 and     dl,toupper             ;
  84.                 sub     dl,'A'                 ;
  85.                 inc     dl                     ;
  86.                 cmp     dl, 2                  ; drive B:
  87.                 jle     bios_method            ; jmp A: or B:
  88. ;               je      bios_method            ;
  89.                 jmp     get_info               ;
  90. set_default:    xor     dl,dl                  ;
  91. get_info:       push    ds                     ;
  92.                 push    bx                     ;
  93.                 mov     ah,36h                 ;
  94.                 int     dos_int                ;
  95.                 cmp     ax, 0FFFFh             ;
  96.                 jne     resetvec               ;
  97.                 mov     cs:errorflag, 1        ;
  98.                 jmp     resetvec               ;
  99. ;----------------------------------------------------------------------------
  100. bios_method:    push    ds                     ;
  101.                 push    bx                     ;
  102.                 mov     ah, 02h                ; read floppy
  103.                 xor     ch, ch                 ; track 0
  104.                 mov     cl, 1                  ; sector 1
  105.                 mov     al, cl                 ; 1 sector
  106.                 xor     dh, dh                 ; head 0, dl contains drive
  107.                 dec     dl                     ; drive a = 0, b = 1
  108.                 mov     bx, offset cs:sector_buffer
  109.                 push    es                     ;
  110.                 push    cs                     ;
  111.                 pop     es                     ;
  112.                 int     13h                    ; rom interrupt
  113.                 pop     es                     ;
  114.                 jnc     resetvec               ; no error
  115.                 mov     cs:errorflag, 1        ; error occured
  116.                 xor     ax, ax                 ; reset disk
  117.                 int     13h                    ;
  118. ;----------------------------------------------------------------------------
  119. resetvec:       mov     ah,25h                 ; 
  120.                 mov     al,vect_num1           ;
  121.                 mov     dx, word ptr old_v_1   ;
  122.                 mov     ds, word ptr old_v_1[2];
  123.                 int     dos_int                ;
  124. ;----------------------------------------------------------------------------
  125.                 pop     bx                     ;
  126.                 pop     ds                     ;
  127. exit:           xor     ah,ah                  ;
  128.                 mov     al,cs:errorflag        ;
  129.                 xor     ax,1                   ;
  130.                 push    ax                     ;
  131.                 call    __RETL                 ;
  132.                 add     sp,2                   ;
  133.                 pop     bp                     ;
  134.                 retf                           ;
  135. isdrive         endp                           ;
  136. isdrive_text    ends                           ;
  137.                 end  
  138. ;----------------------------------------------------------------------------
  139.